#include "PrecompiledHeader.h"
#include "ICamera.h"

/*--------------------------------------------------------------------------*/

ICamera::ICamera() :
	m_updateFlags(~0),
	m_farDistance(1.0f),
	m_nearDistance(-1.0f),
	m_position(glm::vec3()),
	m_viewMatrix(glm::mat4()),
	m_viewProjectionMatrix(glm::mat4())
{

}

/*--------------------------------------------------------------------------*/

ICamera::ICamera(float farDist, float nearDist) :
	m_updateFlags(~0),
	m_farDistance(farDist),
	m_nearDistance(nearDist),
	m_position(glm::vec3()),
	m_viewMatrix(glm::mat4()),
	m_viewProjectionMatrix(glm::mat4())
{

}

/*--------------------------------------------------------------------------*/

ICamera::~ICamera()
{

}

/*--------------------------------------------------------------------------*/

void ICamera::SetViewport(const glm::vec4& size)
{
	this->m_viewport = size;
	this->m_updateFlags |= ECameraUpdateFlag::ViewportChanged | ECameraUpdateFlag::ProjectionMatrixChanged;
}

/*--------------------------------------------------------------------------*/

const glm::vec4& ICamera::GetViewport() const
{
	return this->m_viewport;
}

/*--------------------------------------------------------------------------*/


const float& ICamera::GetNearDistance() const
{
	return this->m_nearDistance;
}

/*--------------------------------------------------------------------------*/

void ICamera::SetNearDistance(const float& nval)
{
	this->m_nearDistance = nval;
	this->m_updateFlags |= ECameraUpdateFlag::FrustumChanged | ECameraUpdateFlag::ProjectionMatrixChanged;
}

/*--------------------------------------------------------------------------*/

const float& ICamera::GetFarDistance() const
{
	return this->m_farDistance;
}

/*--------------------------------------------------------------------------*/

void ICamera::SetFarDistance(const float& nval)
{
	this->m_farDistance = nval;
	this->m_updateFlags |= ECameraUpdateFlag::FrustumChanged | ECameraUpdateFlag::ProjectionMatrixChanged;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetViewMatrix()
{
	return this->m_viewMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetInvViewMatrix()
{
	return this->m_invViewMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetViewProjectionMatrix()
{
	return this->m_viewProjectionMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetInvViewProjectionMatrix()
{
	return this->m_invViewProjectionMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetProjectionMatrix()
{
	return this->m_projectionMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::mat4& ICamera::GetInvProjectionMatrix()
{
	return this->m_invProjectionMatrix;
}

/*--------------------------------------------------------------------------*/

const glm::vec3& ICamera::GetPosition() const
{
	return this->m_position;
}

/*--------------------------------------------------------------------------*/

void ICamera::SetPosition(const glm::vec3& position)
{
	this->m_position = position;
	this->m_updateFlags |= ECameraUpdateFlag::FrustumChanged | ECameraUpdateFlag::ViewMatrixChanged;
}

/*--------------------------------------------------------------------------*/

const glm::vec3& ICamera::GetViewDirection() const
{
	return this->m_viewdirection;
}

/*--------------------------------------------------------------------------*/

const glm::vec3& ICamera::GetJumpDirection() const
{
	return this->m_jumpdirection;
}

/*--------------------------------------------------------------------------*/

const glm::vec3& ICamera::GetStrafeDirection() const
{
	return this->m_strafedirection;
}

/*--------------------------------------------------------------------------*/